package com.feituan.core.pojo.response.page;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Collections;
import java.util.List;

@Data
@ToString(callSuper = true)
@EqualsAndHashCode()
@NoArgsConstructor
public class PageData<T> {

    private long current;

    private long total;

    private List<T> records = Collections.emptyList();

    private PageData(long current, long total, List<T> records) {
        this.current = current;
        this.total = total;
        if (null != records) {
            this.records = records;
        }
    }

    public static <T> PageData<T> build(long current, long total, List<T> records) {
        return new PageData<T>(current, total, records);
    }
}
